package com.rizzo.android.ui;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;

/**
 * Created with IntelliJ IDEA.
 * User: jalie
 * Date: 12/26/12
 * Time: 5:07 PM
 * To change this template use File | Settings | File Templates.
 */
public class RetardationPageTransformer implements ViewPager.PageTransformer {

    private float screenXOffset;

    public RetardationPageTransformer(Context context) {
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        Display display = wm.getDefaultDisplay();
        screenXOffset = display.getWidth() / 2;
    }

    @Override
    public void transformPage(View page, float position) {
        final float translateValue = position * -screenXOffset;
        if (position > 0) {
            if (translateValue > -screenXOffset) {
                page.setTranslationX(translateValue);
            } else {
                page.setTranslationX(0);
            }
        }
    }

}
